Agent Call Hooks
data class AgentCallHooks(val onStart: suspend (OnStartEvent) -> Unit? = null, val onStepStart: suspend (OnStepStartEvent) -> Unit? = null, val onStepFinish: suspend (OnStepFinishEvent) -> Unit? = null, val onFinish: suspend (OnFinishEvent) -> Unit? = null, val onError: suspend (OnErrorEvent) -> Unit? = null, val onChunk: suspend (OnChunkEvent) -> Unit? = null, val onAbort: suspend (OnAbortEvent) -> Unit? = null, val experimental_onToolCallStart: suspend (OnToolCallStartEvent) -> Unit? = null, val experimental_onToolCallFinish: suspend (OnToolCallFinishEvent) -> Unit? = null)
Per-call lifecycle hooks. These mirror the ones on the agent constructor but apply to a single Agent.generate / Agent.stream invocation — useful for request-scoped logging, tracing, or progress UI.
Both call-site hooks and constructor-site hooks fire (constructor first, then call-site) — neither replaces the other.
Constructors
Link copied to clipboard
constructor(onStart: suspend (OnStartEvent) -> Unit? = null, onStepStart: suspend (OnStepStartEvent) -> Unit? = null, onStepFinish: suspend (OnStepFinishEvent) -> Unit? = null, onFinish: suspend (OnFinishEvent) -> Unit? = null, onError: suspend (OnErrorEvent) -> Unit? = null, onChunk: suspend (OnChunkEvent) -> Unit? = null, onAbort: suspend (OnAbortEvent) -> Unit? = null, experimental_onToolCallStart: suspend (OnToolCallStartEvent) -> Unit? = null, experimental_onToolCallFinish: suspend (OnToolCallFinishEvent) -> Unit? = null)
Properties
Link copied to clipboard
Per-call mirror of the constructor hook — fired after a tool returns or throws.
Link copied to clipboard
Per-call mirror of the constructor hook — fired before a (non-gated) tool executes.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard